package com.focusai.efairy.ui.adapter.report;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.focusai.efairy.R;
import com.focusai.efairy.model.dev.DevType;
import com.focusai.efairy.model.report.AnalyseDataType;
import com.focusai.efairy.utils.DecimalUtils;

import me.drakeet.multitype.ItemViewBinder;

/**
 * Created by luo_guangwen on 2017/9/22.
 */

public class ReportAnalyseDevViewBinder extends ItemViewBinder<AnalyseDataType.OverviewAnalyze, ReportAnalyseDevViewBinder.ViewHolder> {
    //报表饼图的色值
    private Context mContext;
    public ReportAnalyseDevViewBinder(Context context) {
        this.mContext = context;
    }

    @NonNull
    @Override
    protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        View root = inflater.inflate(R.layout.item_report_dev_analyze, parent, false);
        ViewHolder viewHolder = new ViewHolder(root);
        return viewHolder;
    }

    @Override
    protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull AnalyseDataType.OverviewAnalyze item) {
         holder.textDevTypeName.setText(DevType.getDevTypeNameById(10,item.device_type));
         holder.textInstallNum.setText(item.install_number + "");
         holder.textAlarmNum.setText(item.alarm_number + "");
         holder.textAlarmScale.setText(DecimalUtils.formatScale(item.alarm_scale,1).toString());
         holder.textAlarmTimes.setText(item.alarm_times + "");
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        TextView textDevTypeName;
        TextView textInstallNum;
        TextView textAlarmNum;
        TextView textAlarmScale;
        TextView textAlarmTimes;
        ViewHolder(View itemView) {
            super(itemView);
            textDevTypeName = (TextView) itemView.findViewById(R.id.item_dev_type);
            textInstallNum = (TextView) itemView.findViewById(R.id.item_dev_install_number);
            textAlarmNum = (TextView) itemView.findViewById(R.id.item_dev_alarm_number);
            textAlarmScale = (TextView) itemView.findViewById(R.id.item_dev_alarm_scale);
            textAlarmTimes = (TextView) itemView.findViewById(R.id.item_dev_alarm_times);
        }

    }
}
